﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GraphicsLib;
using TowerDefence.Tiles;

namespace TowerDefence
{
    public interface IMonster { }

    public enum eMonsterState
    {
        Alive,
        Dead
    }

    public class Monster : OldEntity
    {
        public eMonsterState State { get; private set; }
        public eAIDir Direction    { get; private set; }

        private ITileLocator tileLocator;
        private eAIPath path;        

        public Monster(
            Point _pos, 
            CollisionShape _shape, 
            int _health, 
            ITileLocator _tileLocator,
            eAIPath _path
        ) : base(_pos, _shape, _health) 
        { 
            this.State = eMonsterState.Alive;
            this.tileLocator = _tileLocator;
            this.path = _path;
        }

        public override void ModifyHealth(int _mod)
        {
            base.ModifyHealth(_mod);
            if (this.Health <= 0)
            {
                this.State = eMonsterState.Dead;
            }
        }

        public override void Update(GameTime _gameTime)
        {
            base.Update(_gameTime);

            var tile = (PathTile)this.tileLocator.GetTile(this.Position);
            this.Direction = tile.GetDirectionForPath(this.path);
        }
    }
}
